package cn.piaoyi.service.imp;

import java.io.IOException;
import java.io.InputStream;
import java.util.*;

import org.apache.commons.logging.*;

import cn.piaoyi.bean.Address;
import cn.piaoyi.bean.Admin;
import cn.piaoyi.dao.AddressDAO;
import cn.piaoyi.dao.AdminDAO;
import cn.piaoyi.exception.PiaoyiException;
import cn.piaoyi.service.AddressService;
import cn.piaoyi.service.AdminService;


public class AddressServiceImp implements AddressService {

	private static final Log logger = LogFactory.getLog(AddressServiceImp.class);
	
	private AddressDAO addressDAO;

	public AddressDAO getAddressDAO() {
		return addressDAO;
	}

	public void setAddressDAO(AddressDAO addressDAO) {
		this.addressDAO = addressDAO;
	}

	/**
	 * 保存Address对象
	 * 
	 * @param admin
	 * 			Address对象
	 * @return Address
	 * 			Address对象
	 */
	public Address createAddress(Address address) throws PiaoyiException{
		try {
			address = this.getAddressDAO().saveAddress(address);
			return address;
		} catch (Exception e) {
			logger.error(e);
			throw new PiaoyiException(e);
		}
	}

	/**
	 * 保存Address对象
	 * 
	 * @param address
	 * 			Address对象
	 * @return Address
	 * 			Address对象
	 */
	public Address updateAddress(Address address) throws PiaoyiException{
		try {
			address = this.getAddressDAO().updateAddress(address);
			return address;
		} catch (Exception e) {
			logger.error(e);
			throw new PiaoyiException(e);
		}
	}
	
	/**
	 * 根据主键UID获取Address对象
	 * 
	 * @param uid
	 * 			主键ID
	 * @return Address
	 * 			Address对象
	 */
	public Address finAddressByUId(long uid){
		return this.getAddressDAO().finAddressByUId(uid);
	}
}
